﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cesave.DistributedServices.PermisosModule.WindowsHost.ViewModelBase;
using Cesave.DistributedServices.PermisosModule.WindowsHost.Views.Catalogs.Financiamientos;
using System.Globalization;
using Cesave.DistributedServices.PermisosModule.WindowsHost.Resources;

namespace Cesave.DistributedServices.PermisosModule.WindowsHost.ViewModels.Catalogs.Financiamientos
{
	public partial class FinanciamientosViewModel
		: ObservableObject
	{
		#region Private properties

		/// <summary>
		/// 
		/// </summary>
		private FinanciamientosView _view;

		#endregion

		#region Constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="view"></param>
		public FinanciamientosViewModel(FinanciamientosView view)
		{
			if (view == null)
				throw new ArgumentNullException("view");
			_view = view;
			WireUpEvents();
			InitModels();
		}

		#endregion

		#region Event methods

		/// <summary>
		/// 
		/// </summary>
		private void WireUpEvents()
		{
			PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FinanciamientosViewModel_PropertyChanged);
			_view.Load += LoadView;
			_view.closeButton.Click += (sender, e) =>
			{
				_view.Close();
			};
			_view.saveButton.Click += SaveFinanciamientos;
			_view.financiamientoBindingNavigatorSaveItem.Click += SaveFinanciamientos;
			_view.newButton.Click += AddNewFinanciamiento;
			_view.bindingNavigatorAddNewItem.Click += AddNewFinanciamiento;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void FinanciamientosViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
		{
			switch (e.PropertyName)
			{
				default:
					break;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void LoadView(object sender, EventArgs e)
		{
			_view.Text = string.Format(
				CultureInfo.InvariantCulture,
				WindowTitles.FinanciamientosWindowTitle
			);
		}

		#endregion

		#region Private methods

		/// <summary>
		/// 
		/// </summary>
		private void InitModels()
		{
		}

		#endregion
	}
}
